<?php
defined('BASEPATH') OR exit('No direct script access allowed');
 
class HomeLarge extends AdminTwoController {

	function __construct() {
		parent::__construct();
		$this->load->model("Attend_model");
		$this->load->model('Admin_model');
		$this->load->model('Select_model');
		$this->load->model('Student_feedback_model');
		$this->load->model('Table1_model');
		$this->load->model('Table2_model');
		$this->load->model('Table3_model');
		$this->load->model('Table4_model');
		$this->load->model('Table5_model');
		$this->load->model('Table6_model');
		// $this->load->model('Supervisor_feedback_model');
		// $this->load->model('Supervisor_feedback_record_model');	
		$this -> load -> model("Classes_number_model");
		$this -> load -> model("Image_text_model");
	}

	function Index() {
		

		
		$data['ImgText'] = $this->getImgText();//图文信息
		$classes_number = $this->classes_number();//专项听课次数折线图
		$data['course_units'] = (new AdminDeptList)->getRemark()[1];//所有开课单位
		 $years = $this->getYearsSince(2020);//所有年份
		 arsort($years);//最新年份降序排列
		$data['yearlist'] =$years; 
		$title = array_column($classes_number,'title');
		$number = array_column($classes_number,'number');
		$data['classes_number'] = json_encode($classes_number);
		$data['title'] = json_encode($title);
		$data['number'] = json_encode($number);
		$data['course_units_json'] = json_encode($data['course_units']);
		
		$data['home_pop_status'] = $this->getHomePopStatus();
		$data['home_user_id'] = getSess()['id'];
		// echo '<pre>';
		// var_dump($data['home_pop_status'] );
		// exit;
		$this->load->view('admin/homeindex',$data);	
	}

	//获取学年，分院基础信息
	// function getbasicdata(){
	// 	$data['course_units'] = (new AdminDeptList)->getRemark()[1];
	// 	// $data['year_list'] =  array('2024','2023','2022','2021','2020');
	// 	$data['yearlist'] = $this->getYearsSince(2019);
	// 	echo json_encode(array('code'=>0,'data'=>$data));
	// }
	
	//不同类型项目统计
	function getTotalNum(){
		$year = $_POST['year'];
		$start_time = $year.'-01-01 00:00:00';
		$end_time = $year.'-12-31 23:59:59';

		//查询校督导全年的听课总次数
		$sql = "SELECT count(*) attend_count_school FROM db_attend  WHERE type = '".AttendType::School[XPHEnum::Value]."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";
		$school = $this->Attend_model->query($sql);
		$school_num = 0;
		if($school){
			$school_num = $school[0]['attend_count_school'];
		}
		//查询二级督导全年听课总次数
		//2023年开始按需听课老师统计,之前的按原来所有老师统计
		if(isset($start_time) && isset($end_time) && date("Y",strtotime($start_time)) > 2022){
			$sql2 = "SELECT count(*) attend_count FROM db_listen_teacher_info lt LEFT JOIN db_attend ON db_attend.listen_name = lt.username  WHERE type = '".AttendType::Unit[XPHEnum::Value]."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";		
		}else{
			$sql2 ="SELECT count(*) attend_count FROM db_attend  	WHERE 	type = '".AttendType::Unit[XPHEnum::Value]."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";
		}
		$Unit = $this->Attend_model->query($sql2);
		$unit_num = 0;
		if($Unit){
			$unit_num = $Unit[0]['attend_count'];
		}

		//查询其他身份听课总次数
		$sql3 ="SELECT 	count(*) attend_count_other FROM db_attend  WHERE (type = '3' or type = '4' or type ='5' or type = '6')  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";
		$other = $this->Attend_model->query($sql3);
		$other_num = 0;
		if($other){
			$other_num = $other[0]['attend_count_other'];
		}

		$data['school_num'] = $school_num;
		$data['unit_num'] = $unit_num;
		$data['other_num'] = $other_num;

		$listen_type = $this -> Select_model -> get_list(array('type'=>SelectType::ListenType[XPHEnum::Value],'status'=>CommonStatus::UnDeleted[XPHEnum::Value]));
		
		foreach($listen_type as $k=>$v){
			if($v['option'] == "日常听课"){
				unset($listen_type[$k]);
			}
		}
		$listen_type_new= array_column($listen_type,'option');
		

		$listen_arr = array();
		foreach($listen_type_new as $k1=>$v1){
			$listen_arr[$k1]['title'] = $v1;
			//统计年度听课类型的总次数
			$sql4 = "SELECT count(*) zxtkcs FROM db_attend  WHERE listen_type = '".$v1."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";
			$zxtkcs = $this->Attend_model->query($sql4);
			$listen_arr[$k1]['number'] = $zxtkcs[0]['zxtkcs']?$zxtkcs[0]['zxtkcs']:'0';
		}

		$data['title'] = array_column($listen_arr,'title');
		$data['number'] = array_column($listen_arr,'number');
		echo json_encode(array('code'=>0,'data'=>$data));
	} 

	//专项听课次数
	function classes_number(){
		$connar['items']="title,number";
		$connar['where']="status=1";
		$list = $this -> Classes_number_model -> get_list_full($connar);
		return $list;
		// echo json_encode(array('code'=>0,'data'=>$list));
	}


	//二级学院监控评价数据情况 
	function getSecondaryNum(){
		$year = $_POST['year'];	$course_units = $_POST['course_units'];
		$start_time = $year.'-01-01 00:00:00';
		$end_time = $year.'-12-31 23:59:59';
		//校督导听课次数
		$sql1 = "SELECT count(*) attend_count_school FROM 	db_attend  WHERE course_units = '".$course_units."' and type = '".AttendType::School[XPHEnum::Value]."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";
		$school = $this->Attend_model->query($sql1);
		$school_num = 0;
		if($school){
			$school_num = $school[0]['attend_count_school'];
		}
		// var_dump($school_num);
		//查询二级督导分院全年听课总次数
		//2023年开始按需听课老师统计,之前的按原来所有老师统计
		if(isset($start_time) && isset($end_time) && date("Y",strtotime($start_time)) > 2022){

			// $sql2 = "SELECT count(*) attend_count FROM db_listen_teacher_info lt LEFT JOIN db_attend ON db_attend.listen_name = lt.username  WHERE lt.course_units = '".$course_units."' and type = '".AttendType::Unit[XPHEnum::Value]."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";		


			$sql2 = "SELECT count(*) attend_count FROM 	db_attend  WHERE course_units = '".$course_units."' and type = '".AttendType::Unit[XPHEnum::Value]."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";

		}else{
			$sql2 ="SELECT count(*) attend_count FROM db_attend  	WHERE course_units = '".$course_units."' and	type = '".AttendType::Unit[XPHEnum::Value]."'  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";
		}
		$Unit = $this->Attend_model->query($sql2);
		
		$unit_num = 0;
		if($Unit){
			$unit_num = $Unit[0]['attend_count'];
		}
		// var_dump($unit_num);
		//查询其他身份听课总次数
		$sql3 ="SELECT 	count(*) attend_count_other FROM db_attend  WHERE course_units = '".$course_units."' and (type = '3' or type = '4' or type ='5' or type = '6')  AND STATUS = ".AttendStatus::Submit[XPHEnum::Value]."  AND db_attend.listen_time >= ".strtotime($start_time)."  AND db_attend.listen_time <= ".strtotime($end_time)." ;";
		$other = $this->Attend_model->query($sql3);
		$other_num = 0;
		if($other){
			$other_num = $other[0]['attend_count_other'];
		}
		// var_dump($other_num);
		//调研次数
		$dysql ="SELECT count(*) table1Time FROM `db_table1` LEFT JOIN `db_admin` ON `db_admin`.`id`=`db_table1`.`admin_id` WHERE `dept_name` = '".$course_units."' and `db_table1`.`sub_time` > ".strtotime($start_time)." and `db_table1`.`sub_time` < ".strtotime($end_time)."; ";
		$table1Time = $this->Table1_model->query($dysql);
		$dy_num = 0;
		if($table1Time){
			$dy_num = $table1Time[0]['table1Time'];
		}
		//信息员反馈次数
		$fksql ="SELECT count(*) feedbackTime  FROM (SELECT * FROM db_student_feedback UNION ALL SELECT * FROM db_supervisor_feedback ) feedback
		LEFT JOIN db_admin ON feedback.creator = db_admin.id  WHERE del_flag = ".CommonStatus::UnDeleted[XPHEnum::Value] . "  AND (feedback.STATUS = " . FeedBackStatus::HaveWrite[XPHEnum::Value] . " OR feedback.STATUS = " . FeedBackStatus::End[XPHEnum::Value] . " )  AND db_admin.dept_name = '".$course_units."'  AND feedback.created > ".strtotime($start_time)." AND feedback.created < ".strtotime($end_time)."; ";
		$feedbackTime = $this->Student_feedback_model->query($fksql);
		$feedback_num = 0;
		if($feedbackTime){
			$feedback_num = $feedbackTime[0]['feedbackTime'];
		}
		//日常寻检查次数
		$xcsql ="SELECT count(*) table2Time FROM `db_table2` LEFT JOIN `db_admin` ON `db_admin`.`id`=`db_table2`.`admin_id` WHERE `dept_name` = '".$course_units."' and `db_table2`.`sub_time` > ".strtotime($start_time)." and `db_table2`.`sub_time` < ".strtotime($end_time)."; ";
		$table2Time = $this->Table2_model->query($xcsql);
		$xc_num = 0;
		if($table2Time){
			$xc_num = $table2Time[0]['table2Time'];
		}
		//巡考
		$xksql = "	SELECT count(*) table3Time FROM `db_table3` LEFT JOIN `db_admin` ON `db_admin`.`id`=`db_table3`.`admin_id` WHERE `dept_name` = '".$course_units."' and `db_table3`.`sub_time` > ".strtotime($start_time)." and `db_table3`.`sub_time` < ".strtotime($end_time)."; ";
		$table3Time = $this->Table3_model->query($xksql);
		$xk_num = 0;
		if($table3Time){
			$xk_num = $table3Time[0]['table3Time'];
		}
		//定岗实习
		$dgsxsql = "	SELECT count(*) table4Time FROM `db_table4` LEFT JOIN `db_admin` ON `db_admin`.`id`=`db_table4`.`admin_id` WHERE `dept_name` = '".$course_units."' and `db_table4`.`sub_time` > ".strtotime($start_time)." and `db_table4`.`sub_time` < ".strtotime($end_time)."; ";
		$table4Time = $this->Table4_model->query($dgsxsql);
		$dgsx_num = 0;
		if($table4Time){
			$dgsx_num = $table4Time[0]['table4Time'];
		}
		//专项检查次数
		$zxjcsql ="SELECT count(*) table5Time FROM `db_table5` LEFT JOIN `db_admin` ON `db_admin`.`id`=`db_table5`.`admin_id` WHERE `dept_name` = '".$course_units."' and `db_table5`.`sub_time` > ".strtotime($start_time)." and `db_table5`.`sub_time` < ".strtotime($end_time)."  and `db_table5`.`status` = '1' ;";
		$table5Time = $this->Table5_model->query($zxjcsql);
		$zxjc_num = 0;
		if($table5Time){
			$zxjc_num = $table5Time[0]['table5Time'];
		}

		//专题调查次数
		$ztdcsql = "SELECT count(*) table6Time FROM `db_table6` LEFT JOIN `db_admin` ON `db_admin`.`id`=`db_table6`.`admin_id` WHERE `dept_name` = '".$course_units."' and `db_table6`.`sub_time` > ".strtotime($start_time)." and `db_table6`.`sub_time` < ".strtotime($end_time)."; "; 
		$table6Time = $this->Table6_model->query($ztdcsql);
		$ztdc_num = 0;
		if($table6Time){
			$ztdc_num = $table6Time[0]['table6Time'];
		}

		$data['datatitle'] = array('校级督导听课次数', '二级督导听课次数', '其他监控人员听课次数', '调研次数', '信息员反馈次数', '日常巡检查次数','巡考次数','顶岗实习检查次数','专项检查次数');
		$data['datalist'] = array($school_num,$unit_num,$other_num,$dy_num,$feedback_num,$xc_num,$xk_num,$dgsx_num,$zxjc_num);

		echo json_encode(array('code'=>0,'data'=>$data));

	}


	
	//图文内容接口
	function getImgText(){
		//公告通知
		$sql1 = " select id,title,content,type,from_unixtime(created,'%Y-%m-%d') createdStr from db_image_text where status=1 and type=".ImageType::First[XPHEnum::Value]." order by created desc limit 6";
		$data['ggtz'] = $this -> Image_text_model -> query($sql1);
		//工作动态
		$sql2 = " select id,image_url,title,content,type,from_unixtime(created,'%Y-%m-%d') createdStr from db_image_text where status=1 and type=".ImageType::Second[XPHEnum::Value]." order by created desc limit 6";
		$data['gzdt'] = $this -> Image_text_model -> query($sql2);
		//制度文件
		$sql3 = " select id,file_url,filename,title,type,from_unixtime(created,'%Y-%m-%d') createdStr from db_image_text where status=1 and type=".ImageType::Third[XPHEnum::Value]." order by created desc limit 6";
		$data['zdwj'] = $this -> Image_text_model -> query($sql3);
		//质量简报
		$sql4 = " select id,file_url,filename,title,type,from_unixtime(created,'%Y-%m-%d') createdStr from db_image_text where status=1 and type=".ImageType::Fourth[XPHEnum::Value]." order by created desc limit 6";
		$data['zljb'] = $this -> Image_text_model -> query($sql4);

		$data['gzdt_img'] = array();
		foreach($data['gzdt'] as $k=>$v){
			if($v['image_url'] != ""){
				$data['gzdt_img'][] = $v; 
			}
		}
		return $data;
		// echo json_encode(array('code'=>0,'data'=>$data));
	}

	//获取指定年份到当前年份中间的所有年份
	function getYearsSince($startYear) {
		$currentYear = date("Y"); // 获取当前年份
		$years = [];
		for ($i = $startYear; $i <= $currentYear; $i++) {
			$years[] = $i;
		}
		return $years;
	}

	//图文详情页
	function detail($id,$type){
		if($type == 1){
			$item = "id,title,content,type,from_unixtime(created,'%Y-%m-%d') createdStr";
		}elseif($type == 2){
			$item = "id,image_url,title,content,type,from_unixtime(created,'%Y-%m-%d') createdStr";
		}elseif($type == 3){
			$item = "id,file_url,filename,title,content,type,from_unixtime(created,'%Y-%m-%d') createdStr";
		}elseif($type == 4){
			$item = "id,file_url,filename,title,content,type,from_unixtime(created,'%Y-%m-%d') createdStr";
		}

		$sql1 = " select ".$item." from db_image_text where status=1 and type = ".$type."  and id =".$id;
	
		$list = $this -> Image_text_model -> query($sql1);
		if($list){
			$data['detail'] = $list[0]?$list[0]:array();
			$data['Title'] =(new ImageType)->show($type) ; 
			$this->load->view('admin/homedetail',$data);	
		}else{
			echo "该文章不存在或已被删除";
		}
	
		
	}




	protected  function getHomePopStatus(){
		$this->load->model('Supervisor_feedback_model');
		$role=explode(',',getSess()['sub_role_id']);
		array_push($role,getSess()['role_id']);
		// foreach ($role as $k => $v) {
		if(in_array(WebRole::Manage[XPHEnum::Value],$role)){//13
				$data['feedbackcount']=$this->Supervisor_feedback_model->query('select count(*)as count from(select * from db_student_feedback union all select * from db_supervisor_feedback) feedback where role_belong='.WebRole::Manage[XPHEnum::Value].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong=0 and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]);
				//pri($data['feedbackcount']);

				$feedback_list = $this->Supervisor_feedback_model->query('select * from(SELECT db_student_feedback.*,a.role_id,a.sub_role_id FROM db_student_feedback LEFT JOIN db_admin a on a.id = db_student_feedback.creator UNION ALL SELECT db_supervisor_feedback.*,a1.role_id,a1.sub_role_id FROM db_supervisor_feedback LEFT JOIN db_admin a1 on a1.id = db_supervisor_feedback.creator) feedback where role_belong='.WebRole::Manage[XPHEnum::Value].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong=0 and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]." group by role_id ");


				$data['feedbackcountTeacher']=$this->Supervisor_feedback_model->query('select count(*)as count from(select * from db_student_feedback union all select * from db_supervisor_feedback) feedback where role_belong='.WebRole::Manage[XPHEnum::Value].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong='.getSess()['id'].' and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]);

				$feedback_list_1=$this->Supervisor_feedback_model->query('select * from(SELECT db_student_feedback.*,a.role_id,a.sub_role_id FROM db_student_feedback LEFT JOIN db_admin a on a.id = db_student_feedback.creator UNION ALL SELECT db_supervisor_feedback.*,a1.role_id,a1.sub_role_id FROM db_supervisor_feedback LEFT JOIN db_admin a1 on a1.id = db_supervisor_feedback.creator) feedback where role_belong='.WebRole::Manage[XPHEnum::Value].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong='.getSess()['id'].' and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]." group by feedback.role_id "); 

			}else if(in_array(WebRole::UnitSupervisorGroupLeader[XPHEnum::Value],$role)){ // 5
				$data['feedbackcount']=$this->Supervisor_feedback_model->query('select count(*)as count from(select * from db_student_feedback union all select * from db_supervisor_feedback) feedback LEFT JOIN db_admin a1 on a1.id=feedback.creator where feedback.status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and a1.dept_name="'.getSess()['dept_name'].'" and role_belong='.WebRole::UnitSupervisorGroupLeader[XPHEnum::Value].' and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value].' and belong=0');

			//	pri($data['feedbackcount']);

				$feedback_list = $this->Supervisor_feedback_model->query('select * from(SELECT db_student_feedback.*,a.role_id,a.sub_role_id FROM db_student_feedback LEFT JOIN db_admin a on a.id = db_student_feedback.creator UNION ALL SELECT db_supervisor_feedback.*,a1.role_id,a1.sub_role_id FROM db_supervisor_feedback LEFT JOIN db_admin a1 on a1.id = db_supervisor_feedback.creator) feedback LEFT JOIN db_admin a1 on a1.id=feedback.creator where feedback.status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and a1.dept_name="'.getSess()['dept_name'].'" and role_belong='.WebRole::UnitSupervisorGroupLeader[XPHEnum::Value].' and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value].' and belong=0  group by feedback.role_id ');

				$data['feedbackcountTeacher']=$this->Supervisor_feedback_model->query('select count(*)as count from(select * from db_student_feedback union all select * from db_supervisor_feedback) feedback LEFT JOIN db_admin a1 on a1.id=feedback.creator where feedback.status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and a1.dept_name="'.getSess()['dept_name'].'" and role_belong='.WebRole::UnitSupervisorGroupLeader[XPHEnum::Value].' and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value].' and belong='.getSess()['id']);			

				$feedback_list_1=$this->Supervisor_feedback_model->query('select * from(SELECT db_student_feedback.*,a.role_id,a.sub_role_id FROM db_student_feedback LEFT JOIN db_admin a on a.id = db_student_feedback.creator UNION ALL SELECT db_supervisor_feedback.*,a1.role_id,a1.sub_role_id FROM db_supervisor_feedback LEFT JOIN db_admin a1 on a1.id = db_supervisor_feedback.creator) feedback LEFT JOIN db_admin a1 on a1.id=feedback.creator where feedback.status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and a1.dept_name="'.getSess()['dept_name'].'" and role_belong='.WebRole::UnitSupervisorGroupLeader[XPHEnum::Value].' and del_flag='.CommonStatus::UnDeleted[XPHEnum::Value].' and belong='.getSess()['id']);	

			}else{
				$data['feedbackcount']=$this->Supervisor_feedback_model->query('select count(*)as count from(select * from db_student_feedback union all select * from db_supervisor_feedback) feedback where belong='.getSess()['id'].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong=0 and  del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]);
				//pri($data['feedbackcount']);

				$feedback_list = $this->Supervisor_feedback_model->query('select * from(SELECT db_student_feedback.*,a.role_id,a.sub_role_id FROM db_student_feedback LEFT JOIN db_admin a on a.id = db_student_feedback.creator UNION ALL SELECT db_supervisor_feedback.*,a1.role_id,a1.sub_role_id FROM db_supervisor_feedback LEFT JOIN db_admin a1 on a1.id = db_supervisor_feedback.creator) feedback where belong='.getSess()['id'].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong=0 and  del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]." group by feedback.role_id ");

				$data['feedbackcountTeacher']=$this->Supervisor_feedback_model->query('select count(*)as count from(select * from db_student_feedback union all select * from db_supervisor_feedback) feedback where belong='.getSess()['id'].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong='.getSess()['id'].' and  del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]);
				
				$feedback_list_1= $this->Supervisor_feedback_model->query('select * from(SELECT db_student_feedback.*,a.role_id,a.sub_role_id FROM db_student_feedback LEFT JOIN db_admin a on a.id = db_student_feedback.creator UNION ALL SELECT db_supervisor_feedback.*,a1.role_id,a1.sub_role_id FROM db_supervisor_feedback LEFT JOIN db_admin a1 on a1.id = db_supervisor_feedback.creator) feedback where belong='.getSess()['id'].' and status='.FeedBackStatus::ToAudit[XPHEnum::Value].' and belong='.getSess()['id'].' and  del_flag='.CommonStatus::UnDeleted[XPHEnum::Value]." group by feedback.role_id ");
			}
		// }	
			

			//  
			$home_pop_status = -1;
			foreach($data as $val){
				if(is_array($val)){
					if($val[0]['count'] >0) {
						$home_pop_status =1;
					}
				}
			}

			return $home_pop_status;
	}

}
